package io.renren.modules.sys.service.impl;

import io.renren.modules.sys.entity.FyUsersEntity;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.FyClassgroupCommentDao;
import io.renren.modules.sys.entity.FyClassgroupCommentEntity;
import io.renren.modules.sys.service.FyClassgroupCommentService;


@Service("fyClassgroupCommentService")
public class FyClassgroupCommentServiceImpl extends ServiceImpl<FyClassgroupCommentDao, FyClassgroupCommentEntity> implements FyClassgroupCommentService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<FyClassgroupCommentEntity> page = this.page(
                new Query<FyClassgroupCommentEntity>().getPage(params),
                new QueryWrapper<FyClassgroupCommentEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils queryClassgroupCommentByGroupId(Map<String, Object> params) {
        int pageSize = Integer.parseInt(params.get("limit").toString());  //每页记录数
        int currPage = Integer.parseInt(params.get("page").toString());  //当前页数

        int groupid = Integer.parseInt(params.get("groupid").toString());


        int count = baseMapper.queryListcount(groupid);
        List<FyClassgroupCommentEntity> list = baseMapper.queryListPage((currPage-1)*pageSize,currPage*pageSize,groupid);
        return new PageUtils(list,count,pageSize,currPage);
    }

}
